package loop;

import java.util.Scanner;

public class Base_Conversion {
    public static void main(String[] args) {

        Scanner scanner = new Scanner( System.in ) ;
        int number ;
        String str = "" ;
        System.out.println( "请输入您要转换的数：" ) ;
        number = scanner.nextInt() ;
       /*
       int temp = number ;
       //十进制转二进制
        while( temp / 2 != 0 ){

            str = str + ( temp % 2 ) ;
            temp = temp / 2 ;
        }
        if ( number % 2 != 0) {
            str = str + "1" ;
        }
        StringBuffer str2 =new StringBuffer( str ) ;
        System.out.println( str2.reverse());
        */
        //二进制转十进制
        int i = (int)Math.log10(number) ;
        int j = (int)Math.pow(10,i) ;
        int n ;
        int sum = 0 ;
        while (i >= 0){
            n = number / j % 10;
            sum += (n * Math.pow(2,i)) ;
            j /= 10 ;
            i-- ;
        }
        System.out.println( sum );
    }
}
